--[[
/**
 * 回复伤害值的[0]%血量,最大不超过生命上限的[1]%
 */
 */
]]
---@class BuffEffect44100 : BaseBuffEffect
BuffEffect44100 = ClientFight.CreateClass("BuffEffect44100", ClientFight.BaseBuffEffect)
local t = BuffEffect44100
---@param fight Fight
---@param buff FighterBuff
function t:action(fight, buff, ...)

    local parameters = {...};
    local target = parameters[1];
    local owner = buff.target;
    local skill =  parameters[2];
    local fightResult =  parameters[3];
    local damageType =  parameters[5];
    if (fightResult.state == DamageResultTypeEnum.HEAL) then
    return IBuffEffect.FAIL;
    end
    if (fightResult.damage <= 0) then
    return IBuffEffect.FAIL;
    end
    if (skill.skill.skillBean.f_HurtMethod ~= SkillDamageTypeEnum.MAGIC and
    damageType ~= SkillDamageTypeEnum.MAGIC) then
    return IBuffEffect.FAIL;
    end

    local addHp = fightResult.damage * buff.buffBean.f_BuffEffectValue[1] / Global.TEN_THOUSANDTH;
    local cureEffect = FighterAttributeManager.getFightAttr(owner, FighterAttributeEnum.CURE_EFFECT);
    if (cureEffect < -10000) then
    cureEffect = -10000;
    end
    local cureEffectAdd = addHp * cureEffect / 10000;
    addHp =addHp + cureEffectAdd;

    local maxHp = FighterAttributeManager.getFightAttr(owner, FighterAttributeEnum.HP);
    local maxAddHp = maxHp * buff.buffBean.f_BuffEffectValue[2] / Global.TEN_THOUSANDTH;
    if (addHp > maxAddHp) then
    addHp = maxAddHp;
    end

    if (maxHp - owner.hp < addHp) then
    addHp = maxHp - owner.hp;
    if (addHp < 0) then
    addHp = 0;
    end
    end
    if (addHp == 0)then
        return ClientFight.BaseBuffEffect.action(self,fight, buff, ...);
    end
    local logAddHp = addHp;
    DamageManager.setFighterHp(fight, owner, owner, nil, fightResult.state, addHp,
    owner.hp + addHp, true, false, true);
    --        buffManager.addBuff(fight, buff.getSkill(), owner, owner, false, buff.buffBean.f_BuffEffectValue[2], buff.buffBean.f_BuffEffectValue[3]);
    SkillRoleMgr.savePathFile("[" .. fight.frame .. "][EFFECT]Fighter " .. buff.target.fighterId .. " Buff"
    .. buff.modelId .. " 触发更具伤害百分比回复HP效果，增加HP：" .. logAddHp .. " 触发技能id:" .. skill.skill.skillBean.f_SkillID);

    return ClientFight.BaseBuffEffect.action(self,fight, buff, ...);
end

t.New()